package pri.damai.xiaowu.order.server.manager;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
import pri.damai.xiaowu.common.core.exception.GlobalException;
import pri.damai.xiaowu.common.core.vo.ResultVO;
import pri.damai.xiaowu.goods.client.SkuService;
import pri.damai.xiaowu.goods.common.command.StockReduceCmd;

import java.util.List;

/**
 *
 * @Desc
 * @Author yxf
 * @Date 2022/4/30 20:00
 * 但行好事，莫问前程。
 */
@Component
public class GoodsManager {

    @DubboReference
    SkuService skuService;

    public void reduceStockNum(List<StockReduceCmd> stockReduceCmds) {
        ResultVO<Void> resultVO = skuService.reduceSkus(stockReduceCmds);
        if (!resultVO.isSuccess()) {
            throw new GlobalException(resultVO.getCode(), resultVO.getMsg());
        }
    }

}
